/* This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _GSM_HANDLER_
#define _GSM_HANDLER_

#include <inttypes.h>

#define EVENT_UNKNOWN (0)
#define EVENT_CMTI    (1)
#define EVENT_CMGR    (2)
#define EVENT_CUSD    (4)
#define EVENT_CMTE    (5)

#define MAX_SMS_CONTENT_SIZE  (160)
#define MAX_PHN_NO_LENGTH     (15)

struct s_gsmData{
  int8_t event;
  int8_t smsIndex;
  char senderNumber[MAX_PHN_NO_LENGTH];
  char content[MAX_SMS_CONTENT_SIZE];
};

struct s_replyData{
  char destNumber[MAX_PHN_NO_LENGTH];
  char message[MAX_SMS_CONTENT_SIZE];
};

void gsmConfig(void);
int8_t gsmDecodeIncomingMsg(struct s_gsmData* pGsmData);
int gsmWaitForCallReady(void);
int8_t gsmSendTemperatureRequest(void);
int8_t gsmSendBalanceRequest(void);
void gsmSendSms(struct s_replyData* pReplyData);
void gsmSendSmsContentRequest(int8_t index);
void gsmDeleteSms(int8_t index);

#endif
